package priv.lirenhe.javasuper.io.stream2;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class BufferReaderWriterStream {

	public static void main(String[] args) {

		File sourceFile = new File("F:\\workspace\\java_workspace_01\\huali\\jiwang\\file01");
		File destFile = new File("F:\\workspace\\java_workspace_01\\huali\\jiwang\\file02");
		
		BufferedReader bReader = null;
		BufferedWriter bWriter = null;
		try {
			bReader = new BufferedReader(new FileReader(sourceFile));
			bWriter = new BufferedWriter(new FileWriter(destFile));
			
			String str = null;
			while((str = bReader.readLine()) != null){
				System.out.println(str);
				if(str.equals("你好")){
					continue;
				}
				bWriter.append(str);
//				bWriter.append("\r\n");
				bWriter.newLine();
			}
			
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}finally{
			if(bWriter != null){
				try {
					bWriter.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if(bReader != null){
				try {
					bReader.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
		
	
	}
}
